{% extends "blog/base.html" %}
{% block content %}
<p>类别:
    {% if category.parent_category %}
<a href="{% url 'blog:category_detail' category.parent_category.slug %}">{{ category.parent_category.name }}</a> /
   {% endif %}
<a href="{% url 'blog:category_detail' category.slug %}">{{ category }}</a>
</p>
<h3>博客文章清单</h3>
{# 注释: page_obj不要改。Article可以改成自己对象 #}
{% if page_obj %}
    <ul>
    {% for article in page_obj %}
   <li><a href="{% url 'blog:article_detail' article.id article.slug %}"> {{ article.title }}</a> {{ article.pub_date | date:"Y-m-j" }}</li>
    {% endfor %}
   </ul>
{# 注释: 下面代码一点也不要动 #}
   {% if is_paginated %}
     <ul class="pagination">
    {% if page_obj.has_previous %}
      <li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}">Previous</a></li>
    {% else %}
      <li class="page-item disabled"><span class="page-link">Previous</span></li>
    {% endif %}

    {% for i in paginator.page_range %}
        {% if page_obj.number == i %}
            <li class="page-item active"><span class="page-link"> {{ i }} <span class="sr-only">(current)</span></span></li>
       {% else %}
            <li class="page-item"><a class="page-link" href="?page={{ i }}">{{ i }}</a></li>
       {% endif %}
    {% endfor %}
     {% if page_obj.has_next %}
         <li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}">Next</a></li>
     {% else %}
        <li class="page-item disabled"><span class="page-link">Next</span></li>
    {% endif %}
    </ul>
{% endif %}

{% else %}
{# 注释: 这里可以换成自己的对象 #}
    <p>No article yet.</p>
{% endif %}

{% endblock %}